package com.dianban.service.impl;

import com.dianban.dao.ShoproOrderDao;
import com.dianban.entity.ShoproOrder;
import com.dianban.service.ShoproOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional(readOnly = true)
public class ShoproOrderServiceImpl implements ShoproOrderService {

    @Autowired
    private ShoproOrderDao shoproOrderDao;

    @Override
    @Transactional(readOnly = false)
    public void syncOrder() {
        // 查询出要处理线下核销的订单, 处理这些数据
        // 500能量舱
        shoproOrderDao.sync500Order(ShoproOrder.goodsId_500);
        // 5000能量舱
        shoproOrderDao.sync5000Order(ShoproOrder.goodsId_5000);
    }

    // 核销方式,如果输入500的这种走套餐核销方式,如果其他金额可以使用金豆支付
    //     1.线上500,5000套餐(剩余可用次数)
    //     2.线下5000套餐(剩余可用次数)
    //     3.是否符合上级/上上级有购买5000套餐的这种新客(是否有剩余1次核销)
    //     4.非会员首次50(是否有1次这种现金支付的方式)


    @Override
    public List<ShoproOrder> findVerifyList(Long userId, Long goodsId,Long storeId) {
        return shoproOrderDao.findVerifyList(userId,goodsId,storeId);
    }

    @Override
    public ShoproOrder findById(Long id) {
        return shoproOrderDao.findById(id);
    }

    @Override
    @Transactional(readOnly = false)
    public int updateVerify(Long id, Integer hasVerifyCount, Integer takenewHasVerifyCount) {
        return shoproOrderDao.updateVerify(id,hasVerifyCount,takenewHasVerifyCount);
    }
}
